import React, { Component } from 'react';
import {connect} from 'react-redux'
import { Upload, message, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import ImgCrop from 'antd-img-crop';
import { API_URL } from '../../../../env';

// 引入css
import './index.css'
class UploadEvi extends Component {
    
    render() {

        const { baseUserInfoState, value_data } = this.props

        const props = {
            name: 'TaskEviFile',
            data: {dotask_id: value_data.key, email: baseUserInfoState.email},
            // accept: ".jpg,", // 让用户点开自动过滤其他类型图片，只有jpg图片
            // 可以上传任何类型
            action: API_URL + 'manage/upload_task_evi',
            headers: {
                authorization: 'authorization-text',
            },
            maxCount: 1,
            onChange(info) {
                    if (info.file.status !== 'uploading') {
                    // console.log(info.file, info.fileList);
                    console.log()
                    }
                    if (info.file.status === 'done') {
                    message.success(`${info.file.name} file uploaded successfully`);
                    } else if (info.file.status === 'error') {
                    message.error(`${info.file.name} file upload failed.`);
                    }
                },
        }
        return (
            <div className='uploadEvi'>
                <Upload {...props}>
                    <Button disabled={value_data.task_res[0]!=1 ? true : false} type='dashed' icon={<UploadOutlined />}> 
                    {
                    this.props.task_evi
                    ? 
                        "重新上传"
                    :
                        "上传材料"
                    }
                    </Button>
                </Upload>
            </div>
        )
    }
};
 export default connect(
     state => ({
        baseUserInfoState: state.PublicReducer.baseUserInfo
     }),
     {}
 )(UploadEvi)